# 哈哈哈
# from kubernetes import client, config
# import os
# kubeconfig
# file_path = "/root/.kube/config"
# config.load_kube_config(file_path)
# apps_api = client.AppsV1Api()
#
# for dp in apps_api.list_deployment_for_all_namespaces().items:
#     print(dp)


import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# InsecureRequestWarning: Unverified HTTPS request is being made to host（requests证书警告）



# serviceaccount
from kubernetes import client, config
configuration = client.Configuration()
import os
configuration.host = "https://218.244.158.229:6443"  # APISERVER地址
# configuration.ssl_ca_cert=r"C:\Users\daizhe\Desktop\Pyk8s_Dashboard\PyK8s_Dashboard\api_example\ca.crt"  # CA证书
# configuration.ssl_ca_cert=r"/etc/kubernetes/pki/ca.pem"  # CA证书
configuration.verify_ssl = False   # 启用证书验证
# kubectl describe secret/$(kubectl get secret -nkube-system |grep admin|awk '{print $1}') -nkube-system
token = "eyJhbGciOiJSUzI1NiIsImtpZCI6IlRDM2hwNlM1ak1vUDZ2NjFtNDB4cEIzT0NlRDZzVmxPSFZiYzlqOEdXQzAifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLTV4bGtiIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4NWZiMDMyZC05ZTI2LTRjMDgtOGY2Yi0yNDIwZGMxMTA5NDkiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.JqaGNnGflGQE7ENiXL9JFtwcBcS1PS3-JGmJX7bdStLm6fNENmtKXIa2L5RM8hzX3zwGZEkw3jKX1Ult6ug7e_EU5yXsP0BZ6lNhowfu6C0vYbEX4o-lJV2sX7DHFp9_-urmtjBeXHaf88J3vJ_Fbg8Yv_5Mfk3cCC0yiRZ7EAAUp7d8H2bjVPIvtGSkxFK4WrL0cj0lsrQZg7vgxDbclJJVCpWDDz8NLINjqURpqpfWGo0ABTwYQ_bV8tdXt9hTPAfVDXNTJYm4cHhP-fDQKjkUH-PGzmo56_e-aT24faIOQQEEefgQPw88ScUGY8UgXdfMXTv_tPJj-A588VSmMg"
configuration.api_key = {"authorization": "Bearer " + token}  # 指定Token字符串
client.Configuration.set_default(configuration)
apps_api = client.AppsV1Api()


for dp in apps_api.list_deployment_for_all_namespaces().items:
    print(dp)



